package com.dianrui.agent.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.dianrui.agent.R;

import butterknife.BindView;
import butterknife.ButterKnife;


public class CarMonitorPageAdapter extends BaseAdapter {
    private String[] mTitles = new String[]{"空闲", "使用中", "低电量"};
    private int[] mImages = new int[]{R.mipmap.green_voltale, R.mipmap.yellow_voltage, R.mipmap.red_voltale};
    private Context context;

    public CarMonitorPageAdapter(Context context) {
        this.context = context;
    }


    @Override
    public int getCount() {
        return mTitles.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView != null) {
            holder = (ViewHolder) convertView.getTag();
        } else {
            convertView = LayoutInflater.from(context).inflate(R.layout.carmonitor_item_txt, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }
        holder.tabTxt.setText(mTitles[position]);
        holder.tabImg.setImageResource(mImages[position]);

        return convertView;
    }




     class ViewHolder {
        @BindView(R.id.tab_img)
        ImageView tabImg;
        @BindView(R.id.tab_txt)
        TextView tabTxt;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
